/*
 *  humanmodel.cpp
 *  bgsubtraction
 *
 *  Created by a1gucis on 4/5/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#include "humanmodel.h"

HumanModel::HumanModel() {
	this->headPart = HEAD_PART;
	this->upperBodyPart = UPPER_BODY_PART;
	this->head = NULL;
}

IplImage* HumanModel::getHeadImage(IplImage *image) {
	IplImage *head = cvCreateImage(cvSize(image->width, floor(image->height*headPart)), IPL_DEPTH_8U, 3);
	
	cvSetImageROI(image, cvRect(0, 0, image->width, floor(image->height * headPart)));
	cvCopy(image, head);
	cvResetImageROI(image);
	
	return head;
}

IplImage* HumanModel::getUpperBodyImage(IplImage *image) {
	int upperBodyImageHeight = floor(image->height*upperBodyPart)-floor(image->height*headPart);
	IplImage *upperBody = cvCreateImage(cvSize(image->width, upperBodyImageHeight), IPL_DEPTH_8U, 3);
	
	cvSetImageROI(image, cvRect(0, floor(image->height*headPart), image->width, upperBodyImageHeight));
	cvCopy(image, upperBody);
	cvResetImageROI(image);
	
	return upperBody;
}